package com.andy.blog.common.page;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具
 * Created by andy on 2023/4/8 20:29
 */
public class PageUtilsDTO<E> implements Serializable {

    private static final long serialVersionUID = 2927858272710458891L;

    /**
     * 总共条数
     */
    private long total;

    /**
     * 数据
     */
    private List<E> dataList;

    public PageUtilsDTO() {
    }

    public static <E> PageUtilsDTO<E> build(Long total, List<E> list) {
        return new PageUtilsDTO<>(total, list);
    }

    /**
     * @param list  数据
     * @param total 总数
     */
    public PageUtilsDTO(Long total, List<E> list) {
        this.total = total;
        this.dataList = list;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public List<E> getDataList() {
        return dataList;
    }

    public void setDataList(List<E> dataList) {
        this.dataList = dataList;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.JSON_STYLE);
    }
}

